﻿<#include "include/_meta.html">
<title>车辆列表</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 车辆管理<span
            class="c-gray en">&gt;</span> 车辆记录列表 <a class="btn btn-success radius r"
                                                    style="line-height:1.6em;margin-top:3px"
                                                    href="javascript:location.replace(location.href);" title="刷新"><i
                class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
    <div class="text-c">
        <input type="text" class="input-text" style="width:250px" placeholder="车牌号" id="likecarid" name="">
        <button type="submit" class="btn btn-success" id="searchCar" name=""><i class="Hui-iconfont">&#xe665;</i> 搜用户
        </button>
    </div>
    <div class="cl pd-5 bg-1 bk-gray mt-20"><span class="l"><#--<a href="javascript:;" onclick="datadel()"
                                                               class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>-->
            <a href="javascript:;" id="addCar" class="btn btn-primary radius">
                <i class="Hui-iconfont">&#xe600;</i> 添加车辆</a></span>
        <span class="r">共有数据：<strong id="pageTotal">54</strong> 条</span></div>
    <table id="carTable" class="table table-border table-bordered table-bg table-hover">
        <thead>
        <tr>
            <th scope="col" colspan="9">账户列表</th>
        </tr>
        <tr class="text-c">
            <th width="25"><input type="checkbox" name="caritem" value=""></th>
            <!--<th width="40">ID</th>-->
            <th width="150">车型</th>
            <th width="150">车牌</th>
            <th width="150">日租金</th>
            <th width="150">租赁点</th>
            <th width="130">经手人</th>
            <th width="100">状态</th>
            <th width="100">操作</th>
        </tr>
        </thead>
        <tbody>
        <tr v-for="(item,index) in result" class="text-c">
            <td><input type="checkbox" name="caritem" value=""></td>
            <td>{{item.carModel}}</td>
            <td>{{item.carIdCard}}</td>
            <td>{{item.carPrice}}</td>
            <td>{{item.departmentName}}</td>
            <td>{{item.userName}}</td>
            <td>{{item.carState}}</td>
            <td>
                <a v-if="item.carId!=null" href="#" @click="editEvent(item.carId)">编辑</a>
                <a v-if="item.carId!=null" href="#" @click="delEvent(item.carId)">删除</a>
            </td>
        </tr>
        </tbody>
        <tr>
            <td colspan="2">
                <div id="pagenav"></div>
            </td>
        </tr>
    </table>
</div>

<#include "include/_footer.html">

<script>
    var app = new Vue({
        el: '#carTable',
        data: {
            result: []
        }
    });
    var getCarList = function (curr) {
        $.ajax({
            type: "post",
            dataType: "json",
            url: "/carList",
            data: {
                PageNum: curr || 1,
                carIdCard: $("#likecarid").val(),
                PageSize: 10
            },
            success: function (result) {
                app.result = result.page.records;
                $("#pageTotal").text(result.page.total);
                laypage({
                    cont: "pagenav",
                    first: "首页",
                    pages: result.totalPage,
                    skin: "#DB7023",
                    last: "最后一页",
                    curr: curr || 1,
                    jump: function (obj, first) {
                        if (!first) {
                            loadcheck(obj.curr);
                        }
                    }
                });
            }
        })
    };

    getCarList();

    $("#searchCar").click(function () {
        getCarList();
    });

    //删除
    var delEvent = function (id) {
        layer.confirm("是否确认删除", {
            btn: ['是', '否']
        }, function () {

            console.log("id===" + id);
            $.ajax({
                type: 'POST',
                dataType: 'json',
                url: '/delCar',
                data: {
                    carId: id,
                    carState: 7
                },
                success: function (result) {
                    getCarList();
                    if (result.flag == 1) {
                        layer.msg(result.flag + ":" + result.msg, {icon: 6});
                    } else {
                        layer.msg(result.flag + ":" + result.msg, {icon: 5});
                    }
                }
            });
        }, function () {

        })
    };

    //编辑
    var editEvent = function (id) {
        layer.open({
            type: 2,
            title: "车辆信息编辑",
            fix: false,
            maxmin: true,
            shadeClose: true,
            area: ['1000px', '600px'],
            content: "/toUpdateCar?carId=" + id,
            end: function () {
                getCarList();
            }
        })
    };

    //新增
    $("#addCar").on("click", function () {
        layer.open({
            type: 2,
            title: '添加车辆',
            fix: false,
            maxmin: true,
            shadeClose: true,
            area: ['1000px', '600px'],
            content: 'toAddCar',
            end: function () {
                getCarList();
            }
        });
    });
</script>
</body>
</html>